cmake_minimum_required(VERSION 2.8) 
# Define project name
PROJECT(Output)
message("===== OutPut =====") 
# MESSAGE(STATUS "OS: ${CMAKE_SYSTEM_NAME}")

#Check os
IF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
    SET(MACOSX TRUE)
ENDIF()
IF( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
    SET(LINUX TRUE)
ENDIF()

IF (MACOSX)
    SET(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}")
    #MESSAGE("set MACOSX_DEPLOYMENT_TARGET to '${MACOSX_DEPLOYMENT_TARGET}'.")
ENDIF(MACOSX)

#Set the C++ options
SET(CMAKE_CXX_STANDARD 14)
SET(CXX_EXTENSIONS OFF)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

#Set the flag for checking testing case
SET(TEST_FLAG 0)
IF( ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} )
  SET(TEST_FLAG 1)
  MESSAGE("[Testing Case]: Currently use ${PROJECT_NAME} testing case")
ENDIF()

IF(NOT DEFINED CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE "Release")
ENDIF()

# SET MODULE_OUT_PATH: Be aware of CMAKE_CURRENT_BINARY_DIR
IF( NOT DEFINED MODULE_OUT_PATH )
  SET( MODULE_OUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib/ )
ENDIF()
SET( LIBRARY_OUTPUT_PATH ${MODULE_OUT_PATH} )

SET( TARGET_BUILD_FLAGS
  -Wall
  -pthread
  "$<$<CONFIG:Release>:-O3>"
  "$<$<NOT:$<CONFIG:Release>>:-O0>"
  "$<$<NOT:$<CONFIG:Release>>:-ggdb>"
)

# IF the package has been found, several variables will be SET
if( NOT OpenCV_FOUND)
  find_package(OpenCV 4 REQUIRED)
  if( OpenCV_FOUND )
      message( "Opencv lib is found:" ${OpenCV_INCLUDE_DIRS} )
  endif()
endif()


find_package(Eigen3 REQUIRED )

# Generate static library
  FILE(GLOB SOURCE_FILE
    ${PROJECT_SOURCE_DIR}/*.cpp
  )

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILE})

target_link_libraries(${PROJECT_NAME}
    ${OpenCV_LIBS}
    MapMiddleLayer
    Kalman_filter
    Base
)

target_include_directories( ${PROJECT_NAME} 
  PUBLIC
    ${PROJECT_SOURCE_DIR}
    ${ANDRES_MODULE_PATH}
    ${OpenCV_INCLUDE_DIRS}
    ${EIGEN3_INCLUDE_DIR}
)